package org.neuedu.chapter09_0701.demo05;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTest {
    public static void main(String[] args) {
        String str1 = "2011-09-03";
        String str2 = "2021-03-22";
        // 计算间隔多少天
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        try {
            Date date1 = dateFormat.parse(str1);
            Date date2 = dateFormat.parse(str2);
            long time = date2.getTime() - date1.getTime();
            System.out.println(time / 1000 / 3600 / 24);
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
